<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/common/taglib.jsp" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>待办事务</title>
	<%@include file="/WEB-INF/common/static.jsp" %>
		<script type="text/javascript">
			$(function(){
				$("#mainFrame").attr("height" , window.innerHeight -5 + "px");
				$(window).resize(function(){
					$("#mainFrame").attr("height" , window.innerHeight -5 + "px");
				});
			});
			
			function showNoteDetail(detail){
				$(detail).attr("href","#meetings");
				var taskId = $(detail).find("[name='taskId']").first().val();
				if(taskId == ''){
					alert("请选择任务");
					return;
				}
				$("#taskDetail").load("${ctx}/officeManage/taskManange/taskDetail.do",{
					taskId : taskId
				});
			}
			
			function finishTask(){
				$.post("${ctx}/officeManage/taskManage/finishTask.do",{
					taskId : $("#taskId").val()
				},function(data){
					if(200 == data.code){
		        			alert(data.data);
		        			$(".noteDetail").removeAttr("href");
		        			location.reload();
		        		}else{
		        			alert("确认失败！失败原因：" + data.data);
		        		}
				},"json");
			}
	</script>
</head>
<body>
	    <ul class="nav nav-tabs" role="tablist">
			<li role="presentation" class="active">
				<a href="${ctx}/officeManage/taskManange/showNoFinishedTasks.do">待办任务</a>
			</li>
			<li role="presentation">
				<a href="${ctx}/officeManage/taskManange/showFinishedTasks.do">已完成任务</a>
			</li>
		</ul>
		
		<div id="meetings" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	                <div class="modal-dialog" id="taskDetail">
	                		
	                </div>
	    </div>
        
       	<c:forEach var="userTask"  items="${userTasks }">
			        <div class="list-group sqllist-group" style="padding:10px 50px;margin:0;">
						<a data-toggle="modal"  class="list-group-item noteDetail" onclick="showNoteDetail(this)">
							<input type="hidden" name="taskId" value="${userTask.task.id }">
							<p class="list-group-item-text">
								<span class="meeting_color">[${userTask.group.name }]&nbsp;</span>
								<span class="noteTitle">任务名称：${userTask.task.name }</span>
								<span style="float:right"><fmt:formatDate value="${userTask.task.createTime }" type="both"/></span>
								<span class="publishUser" style="float:right;margin-right:10px;">发布人：${userTask.user.userName }</span>
							</p>
						</a>
					</div>
	       </c:forEach>
	
</body>
</html>